package leetcode_core.leetcode_1;

public class TwoSum3 {
    public int[] twoSum(int[] nums, int target) {
        int left = 0,right = nums.length-1;
        while(left<right){
            int sum = nums[left] + nums[right];
            if(target == sum){
                return new int[]{left,right};
            }else if(sum <target){
                left++;
            }else if(sum > target){
                right++;
            }
        }
        return new int[]{-1,-1};
    }
}
